<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath %>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>农资与农产品全程供应链物流平台-订单录入</title>
<meta name="kewywords" content="农资与农产品全程供应链物流平台"/>
<meta name="description" content="农资与农产品全程供应链物流平台"/>
<link href="css/style.css" type="text/css" rel="stylesheet"/>
<link type="text/css" rel="stylesheet" href="css/jquery-ui.css" />
<script type="text/javascript" src="js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="js/jquery-ui.js"></script>	
<script type="text/javascript" src="js/dialog/lhgdialog.js?skin=default"></script>
<script type="text/javascript">	
	$(function(){
		$("#senddate").datepicker({					
			changeMonth: true,
   			changeYear: true,
   			dateFormat: "yy-mm-dd",
   			showButtonPanel: true,
   			//yearRange: "2012:2050",
   			closeText: "Close",
   			currentText: "Now" 
		});			
	});	
	$(document).ready(function(){		
		if($("#sendDate").val() != "" ){
			//alert($("#sendDate").val());
			$("#senddate").val($("#sendDate").val());
		}
		if($("#tipMessage").val() == "norecord"){
			showTip("查无此条记录，请重新输入订单号码!");
		}else if($("#tipMessage").val() == "success"){
			showTip("保存成功!");
		}
		
		$("#queryBt").click(function(){
			var pattern = new RegExp(/^[0-9-+]+$/);//^表示开始 $表示结束 右方括号（])后跟+号，意味着这个模式可以重复一次或多次
	        var orderid = $("#orderId").val();
	        if($.trim(orderid).length != 12){
	        	$.dialog.alert("请输入12位数字订单号码");
	        	return;
	        }else if(!pattern.test(orderid)){
	        	$.dialog.alert("您输入的号码中含有非数字字符，请重新输入");
	        	return;
	        }
	        window.location.href = "transport/queryOrder.action?orderId=" + orderid;
		});
		
		$("#saveBt").click(function(){
			if($.trim($("#recipient").val()) == ""){
				showTip("请输入收件人姓名");
				return false;
			}
			if($.trim($("#recipienttel").val()) == ""){
				showTip("请输入收件人电话");
				return false;
			}
			if($.trim($("#recipientaddr").val()) == ""){
				showTip("请输入收件人地址");
				return false;
			}
			if($.trim($("#origin").val()) == ""){
				showTip("请填写原寄地");
				return false;
			}
			if($.trim($("#destination").val()) == ""){
				showTip("请填写目的地");
				return false;
			}
			if($.trim($("#quantity").val()) == ""){
				showTip("请填写物品数量");
				return false;
			}
			if($.trim($("#cost").val()) == ""){
				showTip("请填写费用");
				return false;
			}
			if($.trim($("#receiver").val()) == ""){
				showTip("收件员不能为空");
				return false;
			}
			if($.trim($("#senddate").val()) == ""){
				showTip("请填写寄件日期");
				return false;
			}			
			
				$("#sendDate").val($("#senddate").val());
				//alert($("#sendDate").val());
			//window.location.href="transport/saveOrder.action";
			$("#orderInfo").submit();
		});
	});
	function showTip(alertMessage){
		$.dialog({
			title: "提示",
		    time: 5,
		    lock: true,
		    content: alertMessage
		});
	}
	function queryCheck(){
		var pattern = new RegExp(/^[0-9-+]+$/);//^表示开始 $表示结束 右方括号（])后跟+号，意味着这个模式可以重复一次或多次
        var orderid = $("#orderId").val();
        if($.trim(orderid).length != 12){
        	showTip("请输入12位数字订单号码");
        	return;
        }else if(!pattern.test(orderid)){
        	showTip("您输入的号码中含有非数字字符，请重新输入");
        	return;
        }
        $("#queryOrder").submit();
	}
</script>
</head>
<body>
<%@include file="top.jsp" %>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="187" height="37" bgcolor="#e0e0e0" class="brt bbt">
    	<div class="topleft fl">系统菜单栏</div></td>
    <td bgcolor="#e7e7e7" class=" bbt">
    	<div class="topleft fl">您现在的位置：<a href="#">首页</a>&nbsp;>&nbsp;<span>订单录入</span></div>
    </td>
  </tr>
  <tr>
    <td width="187" height="100%" valign="top" bgcolor="#FFFFFF" class="brt">
    <div class="left_bk"> 
        <div class="menu2">
         <%@include file="transport_left.jsp" %>
        </div>
    </div></td>
    <td align="left" valign="top" bgcolor="#FFFFFF">
    <div class="content" >
      <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="38" style="background:url(images/zz_tit.jpg) left top repeat-x;">
	          <div class="tt_back fl">订单录入</div>
	          <div class="fr">
	          	<img src="images/tit_right.jpg" alt="" width="103" height="38" />
	          </div>
          </td>
        </tr>
        <tr>
			<td class="borders btn">
		    	<table width="100%" border="0" cellspacing="0" cellpadding="0">
				  <tr>
				    <td bgcolor="#fffeee" height="41" style="border-bottom:#fee7bd solid 1px;" align="center">
				    <div style="height:450px">
				    <table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
				    	<tr>
						    <td height="41" bgcolor="#fffeee" style="border-bottom:#fee7bd solid 1px;padding-left: 20px;">
						    <form action="transport/queryOrder.action" id="queryOrder" method="post">	
						    	<s:hidden name="tipMessage" id="tipMessage"/>	
							    <table width="100%" border="0" cellspacing="0" cellpadding="0" align="left">
								    <tr>								    
								    <td width="47%" align="right">
								    	订单号：
								    	<input type="text" id="orderId" name="orderId" onblur=""						    		
								    		style="width: 200px;" class="input_are w122" />
								    </td>
								    <td width="3%"></td>
								    <td width="50%" align="left">
								    	<input type="button" value="查  询" id="queryBt" style="cursor: pointer;" class="buttons2" />
								    </td>
								  	</tr>
							  	</table>
							</form>
							</td>
					  	</tr>
					  	<tr>
					  		<td>
					  			<div style="height:400px;overflow-y: scroll;overflow-x: auto;">
					  			<form action="transport/saveOrder.action" method="post" id="orderInfo">
					  			<s:hidden id="sendDate" name="sendDate"/>
					  			<s:if test="order.id != null">
					  			<table id="stockInOrderInfo" width="100%" border="0" cellspacing="1" cellpadding="0" bgcolor="#e3e3e3">
					  				<tr class="captitle">
							            <td height="31" colspan="6"  valign="middle" style="padding-left: 20px;font-weight: bold;">
											订单信息
							            </td>
							        </tr>
					  				<tr style="height: 30px;" bgcolor="#efefef">
										<td align="right" width="10%">订单号：</td>
										<td width="30%" align="left" valign="middle">
											<input type="text" class="input_are" id="orderid" name="order.id" value="${order.id}" readonly/>
										</td>
									    <td align="right" width="10%">寄件日期：</td>
										<td width="50%" align="left" valign="middle">				  				
											<input type="text" id="senddate" class="input_are" value="<s:date name="order.senddate" format="yyyy-MM-dd" />"/>
										</td>
									</tr>
									<tr style="height: 30px;" bgcolor="#efefef">
										<td align="right" width="10%">寄件人姓名：</td>
										<td width="30%"  align="left" valign="middle">
											<input type="text" id="sender" class="input_are" name="order.sender" value="${order.sender}" /></td>
									    <td align="right" width="10%">收件人姓名：</td>
										<td width="50%" align="left" valign="middle">
											<input type="text" id="recipient" class="input_are" name="order.recipient" value="${order.recipient}" /></td>
									</tr>
									<tr style="height: 30px;" bgcolor="#efefef">
										<td align="right" width="10%">寄件人公司：</td>
										<td width="30%" align="left" valign="middle">
											<input type="text" id="senderfirm" class="input_are" name="order.senderfirm" value="${order.senderfirm}" /></td>
									    <td align="right" width="10%">收件人公司：</td>
										<td width="50%" align="left" valign="middle">
											<input type="text"  id="recipientfirm" class="input_are" name="order.recipientfirm" value="${order.recipientfirm}" /></td>
									</tr>
									<tr style="height: 30px;" bgcolor="#efefef">
										<td align="right" width="10%">寄件人电话：</td>
										<td width="30%" align="left" valign="middle">
											<input type="text" id="sendertel" class="input_are" name="order.sendertel" value="${order.sendertel}" /></td>
									    <td align="right" width="10%">收件人电话：</td>
										<td width="50%" align="left" valign="middle">
											<input type="text" id="recipienttel" class="input_are" name="order.recipienttel" value="${order.recipienttel}" /></td>
									</tr>
									<tr style="height: 30px;" bgcolor="#efefef">
										<td align="right" width="10%">寄件人地址：</td>
										<td width="30%" align="left" valign="middle" >												  
											<input type="text" style="width:350px" id="senderaddr" class="input_are" name="order.senderaddr" 
												value="${order.senderaddr}" />						
										</td>				
										<td align="right" width="10%">收件人地址：</td>
										<td width="50%" align="left" valign="middle" >
											<input type="text" style="width:350px" id="recipientaddr" class="input_are" 
												name="order.recipientaddr" value="${order.recipientaddr}"/></td>
									</tr>
									<tr style="height: 30px;" bgcolor="#efefef">
										<td align="right" width="10%">原寄地：</td>
										<td width="30%" align="left" valign="middle">
											<input type="text" id="origin" class="input_are" name="order.origin" value="${order.origin}" /></td>
									    <td align="right" width="10%">目的地：</td>
										<td width="50%" align="left" valign="middle">
											<input type="text" id="destination" class="input_are" name="order.destination" value="${order.destination}" /></td>
									</tr>
									<tr style="height: 30px" bgcolor="#efefef">
										<td align="right" width="10%">规格：</td>
										<td colspan="3" align="left" valign="middle" width="90%">
											数量
											<input type="text" style="width: 60px;" id="quantity" class="input_are" name="order.quantity" value="${order.quantity}" />&nbsp;&nbsp;&nbsp;&nbsp;
											重量
											<input type="text" style="width: 60px;" id="weight" class="input_are" name="order.weight" value="${order.weight}" />kg&nbsp;&nbsp;&nbsp;&nbsp;
											长
											<input type="text" style="width: 60px;" id="length" class="input_are" name="order.length" value="${order.length}" />m&nbsp;&nbsp;&nbsp;&nbsp;
											宽
											<input type="text" style="width: 60px;" id="width" class="input_are" name="order.width" value="${order.width}" />m&nbsp;&nbsp;&nbsp;&nbsp;
											高
											<input type="text" style="width: 60px;" id="height" class="input_are" name="order.height" value="${order.height}" />m&nbsp;&nbsp;
										</td>
									</tr>									
									<tr style="height: 30px;" bgcolor="#efefef">
										<td align="right" width="10%">费用：</td>
										<td width="30%" align="left" valign="middle">				  				
											<input type="text" id="cost" class="input_are"  name="order.cost" value="${order.cost}"/>
										</td>
										<td align="right" width="10%">收件员：</td>
										<td width="50%" align="left" valign="middle">				  				
											<input type="text" id="receiver" class="input_are"  name="order.receiver" value="${order.receiver}"/>
										</td>			  			
									</tr>
									<tr style="height: 30px;" bgcolor="#efefef">											
										<td align="right" width="10%">备注：</td>
										<td width="90%" align="left" valign="middle" colspan="3">				  				
											<input type="text" style="width:350px" id="remark" class="input_are"  name="order.remark" value="${order.remark}"/>
										</td>			  			
									</tr>
									<tr style="height: 40px;">
										<td colspan="2" align="center">
											<input type="button" id="saveBt" style="cursor: pointer;" class="buttons2" value="保  存" />&nbsp;&nbsp;&nbsp;&nbsp;
											<input type="reset" style="cursor: pointer;" class="buttons2" value="重  置" />
										</td>
									</tr>															          
					  			</table>
					  			</s:if>
					  			</form>
					  			</div>
					  		</td>
					  	</tr>		   
				    </table>
				    </div>		   
					</td>
				  </tr>
				</table>
			</td>
        </tr>
      </table>
    </div>
    </td>
  </tr>
</table>
<div class="bottom">版权所有：安徽朗坤物联网</div>
</body>
</html>